import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Cookies from 'js-cookie'
import elementEnLocale from 'element-ui/lib/locale/lang/en'
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'
import elementTwLocale from 'element-ui/lib/locale/lang/zh-TW'
import enLocale from './en_US'
import zhLocale from './zh_CN'
import twLocale from './zh_TW'

Vue.use(VueI18n)

const messages = {
  en_US: {
    ...enLocale,
    ...elementEnLocale
  },
  zh_CN: {
    ...zhLocale,
    ...elementZhLocale
  },
  zh_TW: {
    ...twLocale,
    ...elementTwLocale
  }
}

const i18n = new VueI18n({
  // set locale
  // options: en_US | zh_CN | zh_TW 默认使用中文
  // locale: Cookies.get('lang') || 'zh_TW',
  locale: Cookies.get('lang') || 'zh_CN',
  // set locale messages
  messages
})

export default i18n
